﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using Utils;
using Utils.DatabaseUtils;

namespace Entity
{
    public class OrderBillUI
    {
        private int _O_ID;

        public int O_ID
        {
            get { return _O_ID; }
            set { _O_ID = value; }
        }

        private DateTime _O_Time;

        public DateTime O_Time
        {
            get { return _O_Time; }
            set { _O_Time = value; }
        }

        private string _O_Address;

        public string O_Address
        {
            get { return _O_Address; }
            set { _O_Address = value; }
        }

        private string _O_Phone;

        public string O_Phone
        {
            get { return _O_Phone; }
            set { _O_Phone = value; }
        }

        private string _O_NameCust;

        public string O_NameCust
        {
            get { return _O_NameCust; }
            set { _O_NameCust = value; }
        }

        private string _FolderName;

        public string FolderName
        {
            get { return _FolderName; }
            set { _FolderName = value; }
        }

        private byte _Status;

        public byte Status
        {
            get { return _Status; }
            set { _Status = value; }
        }


        private int _PM_ID;

        public int PM_ID
        {
            get { return _PM_ID; }
            set { _PM_ID = value; }
        }

        private int _cusid;

        public int Cusid
        {
            get { return _cusid; }
            set { _cusid = value; }
        }

        public OrderBillUI() { }
        public OrderBillUI(int O_ID, DateTime O_Time, string O_Address, string O_Phone, string O_NameCust, string FolderName,byte Status, int PM_ID, int cusid)
        {
            this.O_ID = O_ID;
            this.O_Time = O_Time;
            this.O_Address = O_Address;
            this.O_Phone = O_Phone;
            this.O_NameCust = O_NameCust;
            this.FolderName = FolderName;
            this.Status = Status;
            this.PM_ID = PM_ID;
            this.Cusid = cusid;

        }

        public int Add(DateTime O_Time, string O_Address, string O_Phone, string O_NameCust, byte Status, int PM_ID, int cusid)
        {
            try
            {
                int result = SqlHelper.ExecuteNonQuery(Common.Conn, "OrderBill_add", O_Time, O_Address, O_Phone, O_NameCust, Status, PM_ID, cusid);
                return result;
            }
            catch (Exception ex)
            {
                return -1;
            }
        }

        public int Delete(int O_ID)
        {
            try
            {
                int result = SqlHelper.ExecuteNonQuery(Common.Conn, "OrderBill_delete", O_ID);
                return result;
            }
            catch (Exception ex)
            {
                return -1;
            }
        }

        public DataSet Get(int O_ID)
        {
            try
            {
                DataSet result = SqlHelper.ExecuteDataset(Common.Conn, "OrderBill_get", O_ID);
                return result;
            }
            catch (Exception ex)
            {
                return null;
            }
        }

        public DataSet GetByCus(int cusid)
        {
            try
            {
                DataSet result = SqlHelper.ExecuteDataset(Common.Conn, "OrderBill_getbycusid", cusid);
                return result;
            }
            catch (Exception ex)
            {
                return null;
            }
        }

        public DataSet GetAll()
        {
            try
            {
                DataSet result = SqlHelper.ExecuteDataset(Common.Conn, "OrderBill_getall");
                return result;
            }
            catch (Exception ex)
            {
                return null;
            }
        }

        public DataSet Statistic()
        {
            try
            {
                DataSet result = SqlHelper.ExecuteDataset(Common.Conn, "OrderBill_statistic");
                return result;
            }
            catch (Exception ex)
            {
                return null;
            }
        }

        public int Update(int O_ID, DateTime O_Time, string O_Address, string O_Phone, string O_NameCust, string FolderName, byte Status, int PM_ID, int cusid)
        {
            try
            {
                int result = SqlHelper.ExecuteNonQuery(Common.Conn, "OrderBill_update", O_ID, O_Time, O_Address, O_Phone, O_NameCust, FolderName, Status, PM_ID, cusid);
                return result;
            }
            catch (Exception ex)
            {
                return -1;
            }
        }

        public int UpdateFolder(int O_ID, string FolderName)
        {
            try
            {
                int result = SqlHelper.ExecuteNonQuery(Common.Conn, "OrderBill_updatefolder", O_ID, FolderName);
                return result;
            }
            catch (Exception ex)
            {
                return -1;
            }
        }

        public DataSet GetNewOrder()
        {
            try
            {
                DataSet result = SqlHelper.ExecuteDataset(Common.Conn, "OrderBill_getneworder");
                return result;
            }
            catch (Exception ex)
            {
                return null;
            }
        }

        public int ChangeStatus(int O_ID, byte Status)
        {
            try
            {
                int result = SqlHelper.ExecuteNonQuery(Common.Conn, "OrderBill_changestatus", O_ID, Status);
                return result;
            }
            catch (Exception e) { return -1; }
        }

    }

}
